// ? 拼接  地址类
export default class {
  constructor(baseUrl, config) {
    this.baseUrl = baseUrl
    this.config = config
    this.result = {}
    this.loop()
  }

  // * 1是 对象   2是 数组
  loop(parentNode = this.result, config = this.config, type = 1) {
    for (let item in config) {
      if (config[item] instanceof Array) {
        this.loop(parentNode[item] = [], config[item], 2)
      } else if (config[item] instanceof Object) {
        this.loop(parentNode[item] = {}, config[item], 1)
      } else {
        switch (type) {
          case 1: parentNode[item] = this.baseUrl + config[item]
            break
          case 2: parentNode[item] = this.baseUrl + config[item]
            break
          default:
            break
        }
      }
    }
  }
}
